-
Notifications
You must be signed in to change notification settings - Fork 873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jetty-9 httpclient instrumentation, comments please #3079
Jetty-9 httpclient instrumentation, comments please #3079
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution @robododge - would you be able to add library instrumentation too for non-agent users? For example, we have it for Armeria
I think we just need an HttpClient
subclass, something like TracingHttpClient extends HttpClient
and add the logic to send
as I described below, add tracing, wrap listeners, and delegate to super
.
We could either extract an internal
static util to use the same send
logic in the library instrumentation and agent send
interception or possibly instrument the constructors to return TracingHttpClient
.
Is this something you can help with?
...tation/jetty-httpclient/jetty-httpclient-9.0/javaagent/jetty-httpclient-9.0-javaagent.gradle
Outdated
Show resolved
Hide resolved
...tation/jetty-httpclient/jetty-httpclient-9.0/javaagent/jetty-httpclient-9.0-javaagent.gradle
Outdated
Show resolved
Hide resolved
...y/javaagent/instrumentation/jetty/httpclient/v9_0/JettyHttpClient9InstrumentationModule.java
Outdated
Show resolved
Hide resolved
If this is known to be incompatible with 9.0, maybe the whole subproject should use 9.1 in its name rather than 9.0? If the instrumentation does not work correctly on 9.0, then it would be best if the type instrumentation is not applied there. This could be done by restricting it to 9.1+ by implementing |
@agoallikmaa Thanks!
I agree, with the 9.1 focus. Good find on the ProxyConfiguration class. Out of curiosity, is there a good approach or a tool that you could recommend to discover the class deltas from version to version? Or is it just stare-and-compare? |
I'm not aware of any tool for this, I have just been comparing versions manually. |
@anuraaga - Regarding the non-agent usecase, I think I understand the ask, but need to clarify, is non-agent used when someone prefers to simply integrate the tracer code directly with their functional code? Please give me an example of how someone would use it on a non-functional basis. I think my code is close to enough that add a non-agent option wouldn't be much trouble as you explained, just want to make sure I have the usecase right. |
@robododge The use case for library instrumentation is more about wanting to avoid the agent due to some extra overhead, (startup time overhead is unavoidable) and risk by such an invasive process. It's not to integrate tracer code directly into user business logic though, we provide something (interceptor, subclass, hooks, etc) that works with that library so the user can initialize it in their code, but still not really deal with tracing. The unit test for Armeria library vs agent might be informative All the unit tests are the same, the user just required an extra line to initialize using library instrumentation. So in this case, we would probably structure the test to let the library version return the tracing subclass. |
...tation/jetty-httpclient/jetty-httpclient-9.0/javaagent/jetty-httpclient-9.0-javaagent.gradle
Outdated
Show resolved
Hide resolved
...tation/jetty-httpclient/jetty-httpclient-9.0/javaagent/jetty-httpclient-9.0-javaagent.gradle
Outdated
Show resolved
Hide resolved
...y/javaagent/instrumentation/jetty/httpclient/v9_0/JettyHttpClient9InstrumentationModule.java
Outdated
Show resolved
Hide resolved
...io/opentelemetry/javaagent/instrumentation/jetty/httpclient/v9_0/JettyHttpClient9Tracer.java
Outdated
Show resolved
Hide resolved
...telemetry/javaagent/instrumentation/jetty/httpclient/v9_0/JettyHttpClient9LibraryTest.groovy
Outdated
Show resolved
Hide resolved
Another request for help on this PR. I've been going through implementing all the changes as mentioned. All the comments here have steered me toward HttpClient.send() as the place to attach the tracer and also wrap callback listeners. But looks like we have another problem with API drift in the 9.x series. Jetty client 9.2 started using a different method signature for the
My new technique is like this:
|
hey @robododge! just confirming, you mean cutting out v9.1 as well? and keeping 9.2+? |
@robododge Hmm that's an unfortunate change to an exposed method. Do you know if it's possible to implement both to support both versions? Something like // 9.1
protected void send(Request request, List<Response.ResponseListener> listeners) {
Context context = instrumenter.onStart(Context.current, request);
listeners = decorateListeners(listeners, context);
super.send(request, listeners);
}
// 9.2+
protected void send(HttpRequest request, List<Response.ResponseListener> listeners) {
// Looks like our instrumentation can just handle Request
Context context = instrumenter.onStart(Context.current, request);
listeners = decorateListeners(listeners, context);
super.send(request, listeners);
} Not too much duplication |
v9.1 is very old, I would vote to drop it if there's any added complexity to supporting it (EDIT: v9.2.0 was released May 2014) |
@trask - yes proposal right now is drop v9.0, v9.1 |
@anuraaga - the technique I'm using is to actually create a wrapper class that overrides the HttpClient.send(). The code won't compile for example when you you have an v9.2 style |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @robododge!
if you are up for it, check out the new Instrumenter API in #2713, a few http client instrumentations have already been converted which you could use as a guide for this one
...y/javaagent/instrumentation/jetty/httpclient/v9_2/JettyHttpClient9InstrumentationModule.java
Outdated
Show resolved
Hide resolved
...y/javaagent/instrumentation/jetty/httpclient/v9_2/JettyHttpClient9InstrumentationModule.java
Outdated
Show resolved
Hide resolved
...y/javaagent/instrumentation/jetty/httpclient/v9_2/JettyHttpClient9InstrumentationModule.java
Outdated
Show resolved
Hide resolved
...y/javaagent/instrumentation/jetty/httpclient/v9_2/JettyHttpClient9InstrumentationModule.java
Outdated
Show resolved
Hide resolved
...y/javaagent/instrumentation/jetty/httpclient/v9_2/JettyHttpClient9InstrumentationModule.java
Outdated
Show resolved
Hide resolved
...etry/javaagent/instrumentation/jetty/httpclient/v9_2/JettyHttpClient9TracingInterceptor.java
Outdated
Show resolved
Hide resolved
...etry/javaagent/instrumentation/jetty/httpclient/v9_2/JettyHttpClient9TracingInterceptor.java
Outdated
Show resolved
Hide resolved
...pentelemetry/javaagent/instrumentation/jetty/httpclient/v9_2/AbstractJettyClient9Test.groovy
Outdated
Show resolved
Hide resolved
...pentelemetry/javaagent/instrumentation/jetty/httpclient/v9_2/AbstractJettyClient9Test.groovy
Outdated
Show resolved
Hide resolved
...pentelemetry/javaagent/instrumentation/jetty/httpclient/v9_2/AbstractJettyClient9Test.groovy
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Thanks @robododge !
...y/javaagent/instrumentation/jetty/httpclient/v9_2/JettyHttpClient9InstrumentationModule.java
Outdated
Show resolved
Hide resolved
...y/javaagent/instrumentation/jetty/httpclient/v9_2/JettyHttpClient9InstrumentationModule.java
Outdated
Show resolved
Hide resolved
...y/javaagent/instrumentation/jetty/httpclient/v9_2/JettyHttpClient9InstrumentationModule.java
Outdated
Show resolved
Hide resolved
… to underlying jetty-server from the test framework
9cf2f6d
to
b50d84b
Compare
Hi guys, are we good here? I want to get Jetty Http client 10 started after this |
I guess we're waiting for PR builds to come back |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found one minor point that can be addressed (if needed) in a followup. Thanks @robododge
latestDepTestLibrary "org.eclipse.jetty:jetty-client:9.+" | ||
|
||
testImplementation project(':instrumentation:jetty-httpclient:jetty-httpclient-9.2:testing') | ||
testImplementation("org.eclipse.jetty:jetty-server:${jettyVers_base9}") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the test use jetty server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tested without that jetter-server reference, tests passed. So, no it could be removed, want to do that in a PR?
This is my first PR attempt here, I am focusing on Jetty-9 instrumentation only. I am pushing this PR only for help resolving my questions, then I can build the Jetty 8 client.
Test status: 16 passed tests , 2 fails and 5 ignores
I am using a different variation of this Jetty9 client in a live scenario, so I know it mostly works. I appreciate your feedback.
resolves: #2837
EDIT: (6/2/21: All tests pass now, callbacks wrapped properly)